//#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>

using namespace std;
#include<string>
#include<time.h>
#include<ctype.h>
#include<stdlib.h>

struct A{
	int a[1000];
}n;

void TestFunc1(A a) {

}

void TestFunc2(A& a) {

}



A TestFunc3() {
	return n;
}

A& TestFunc4() {
	return n;
}






int mian9() {
	char string[1000];
	strcpy(string, "hello");
	strcat(string, " wawawawa");
	strcat(string, "  zzzzzz");

	printf("%s", string);

	return 0;
}


int main8() {
	char str[] = "This is test";
	for (size_t i = 0; i < sizeof(str)/sizeof(str[0]); i++)
	{
		cout << (char)tolower(str[i])<< endl;
	}

	return 0;

}


int main7() {
	int a[] = { 1,2,3,4,5,6,7,8,9,10 };
	for (auto& e : a)
		e *= 2;
	for (auto e : a)
		cout << e << " ";

	return 0;
}




int main5() {
	int aa = 10;
	int* b = &aa;
	int& c = aa;
	cout << sizeof(b) << endl;
	cout << sizeof(c) << endl;



	return 0;
}

int main6() {
	int arr[] = { 1,2,32,3,4,5,3,6,7 };
	for (size_t i = 0; i < sizeof(arr)/sizeof(arr[0]); i++)
	{
		cout << arr[i] << "  ";
	}
	cout<<endl;
	for (int* p = arr; p < arr + sizeof(arr) / sizeof(arr[0]); ++p) {
		cout << *p << " ";
	}
	cout << endl;

	return 0;
}


int main4() {
	size_t start1 = clock();
	for (size_t i = 0; i < 1000000; i++)
	{
		TestFunc3();
	}
	size_t end1 = clock();

	size_t start2 = clock();
	for (size_t i = 0; i < 1000000; i++)
	{
		TestFunc4();
	}
	size_t end2 = clock();


	cout << end1 - start1 << endl;
	cout << end2 - start2 << endl;
	return 0;

}





int main3() {
	A a;
	A& b = a;
	size_t start1 = clock();
	for (size_t i = 0; i < 1000000; i++)
	{
		TestFunc1(a);
	}
	size_t end1 = clock();

	size_t start2 = clock();
	for (size_t i = 0; i < 1000000; i++)
	{
		TestFunc2(b);
	}
	size_t end2 = clock();


	cout << end1 - start1 << endl;
	cout << end2 - start2 << endl;


	return 0;
}


namespace cml {
	int a=10;
	int add(int a, int b) {
		return a + b;
	}

	namespace cml2 {
		int tmp = 10;
		string func() {
			return "cml2";
		}
	}

	namespace cml3 {

		string func(int a = 10) {
			return "a=" + std::to_string(a);
		}
	}

	namespace cml4{

		int sum1(int a=10,int b=10,int c=20) {
			return a + b + c;
		}

		int sum2(int a, int b = 10, int c = 20) {
			return a + b + c;
		}

		int sum3(int a=89, int b = 10, int c=10 ) {
			return a + b + c;
		}

		 void swap(int& a, int& b) {
			int tmp = a;
			a = b;
			b = tmp;
		}
	}

}


int main2() {

	/*cout << cml::cml4::sum1() << endl;
	cout << cml::cml4::sum2(12) << endl;*/
	//cout << cml::cml4::sum3(1232) << endl;

	

	int a = 10;
	int c = 20;
	cml::cml4::swap(a, c);
	cout << a << endl;
	cout << c << endl;

	int& b = a;
	cout << a << endl;
	cout << b << endl;

	cout << &a << endl;
	cout << &b << endl;



	return 0;
}


int main1() {
	cout << cml::add(12,32) << endl;

	cout << cml::cml2::func() << endl;

	cout << cml::cml3::func(1) << endl;
	cout << cml::cml3::func() << endl;


	return 0;
}